import java.util.ArrayList;
import java.util.Collections;

public  class Iandlords extends Cards {
    //创建三个玩家和底牌集合
    ArrayList<String> w1 =new ArrayList<String>();//玩家一
    ArrayList<String> w2 =new ArrayList<String>();//玩家二
    ArrayList<String> w3 =new ArrayList<String>();//玩家三
    ArrayList<String> hand =new ArrayList<String>();//底牌

    //生成牌
    @Override
    public void create() {
        String[] colors={"♦","♣","♥","♠"};
        String[] numbers={"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
        //将54张牌存入数组
        for(String color:colors){
            for(String number: numbers){
                arr.add(color+number);
            }
        }
        arr.add("小王");
        arr.add("大王");
    }

  //洗牌
    @Override
    public void shuffle() {
        Collections.shuffle(arr);//随机打乱arr集合
    }
   //发牌
    @Override
    public void Licensing() {
        //遍历这副洗好的牌，遍历过程中，将牌发到三个玩家和底牌中
        for(int i=0;i< arr.size();i++){
            String poker = arr.get(i);
            if(i>= arr.size()-3){
                hand.add(poker);
            }
            else{
                if(i%3==0){
                    w1.add(poker);
                }
                else if(i%3==1){
                    w2.add(poker);
                }
                else if(i%3==2){
                    w3.add(poker);
                }
            }

        }

    }
  //看牌
    @Override
    public void show() {
        lookPoker("玩家一", w1);
        lookPoker("玩家2", w2);
        lookPoker("玩家3", w3);
        lookPoker("底牌", hand);
    }
    public static void lookPoker(String name,ArrayList<String> arr) {//看牌方法
        System.out.print(name + "的牌是：");
        for (String poker : arr) {
            System.out.print(poker + " ");
        }
        System.out.println();
    }
}
